<?php require_once('../mysqlUtil.php');
require_once('../islogin.php');
class Goods{
    public $_id;
    public $imagePath;
    public $shopName;
    public $shopNum;
    public $shopPrice;
    public $ShopState;
    public $islimit;
    public $limitNumber;
}

//获取请求参数
$id=$_GET['id'];

//查询数据库
$sql = "SELECT `id`, `name`, `num`, `price`, `state`,
 `islimit`, `limitNumber`, `imagePath` FROM `t_goods` where id=$id;";
//mysqli_query()
$result=$conn->query($sql);

$data = array();
if ($result->num_rows > 0) {
    // 准备返回的json数据
    $goods=new Goods();
    while($row=$result->fetch_assoc()){
        
        $goods->_id=$row['id'];
        $goods->shopName=$row['name'];
        $goods->shopNum=$row['num'];
        $goods->shopPrice=$row['price'];
        $goods->ShopState=$row['state'];
        $goods->islimit=$row['islimit'];
        $goods->limitNumber=$row['limitNumber'];
        $goods->imagePath=$row['imagePath'];
        
        $data[]=$goods;
    }
    echo json_encode(array('state'=>true,'goods'=>$goods));   
    //echo json_encode($data);   
} else {
    $data['state']=false;
    $data['msg']='查询失败';  
    echo json_encode($data);   
}

 
//$conn->close();
?>